﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZX.BLL.Extend;
using ZX.SYS.Library;
using ZX.EHR.Library;


namespace ZX.BLL
{
    public class BDatPhraseDetail : BaseBussnies
    {
        /// <summary>
        /// 根据Value获取字典数据
        /// </summary>
        /// <param name="ClassId">ID</param>
        /// <returns></returns>
        public IList<DatPhraseDetail> GetDatPhraseDetailByClassValue(string ClassValue)
        {
            this.entity = new DatPhraseDetail();
            return GetEntitysBySqlComm<DatPhraseDetail>("select  * from DatPhraseDetail where ClassID=(select ClassID from DatPhraseClass where ClassValue='" + ClassValue + "') order by Seq");
        }
        
        /// <summary>
        /// 根据ClassID获取字典数据
        /// </summary>
        /// <param name="ClassId">ID</param>
        /// <returns></returns>
        public IList<DatPhraseDetail> GetDatPhraseDetailByClassId(Guid ClassId)
        {
            this.entity = new DatPhraseDetail();
            return GetEntitysBySqlComm<DatPhraseDetail>("select * from DatPhraseDetail where ClassID='" + ClassId + "' order by Seq");
        }
        /// <summary>
        /// 根据PhraseID获取字典数据
        /// </summary>
        /// <param name="ClassId">ID</param>
        /// <returns></returns>
        public IList<DatPhraseDetail> GetDatPhraseDetailById(Guid PhraseId)
        {
            this.entity = new DatPhraseDetail();
            return GetEntitysBySqlComm<DatPhraseDetail>("select * from DatPhraseDetail where PhraseID='" + PhraseId + "' order by Seq");
        }
        /// <summary>
        /// 根据PhraseID获取职务
        /// </summary>
        /// <param name="ClassId">ID</param>
        /// <returns></returns>
        public IList<DatDutyInfo> GetDatDutyById(Guid PhraseId)
        {
            this.entity = new DatDutyInfo();
            return GetEntitysBySqlComm<DatDutyInfo>("select * from DatDutyInfo where DutyTypeId='" + PhraseId + "' order by SequenceNo");
        }
        
        /// <summary>
        /// 根据ClassID和PhraseText查找记录是否存在
        /// </summary>
        /// <param name="strText">PhraseText</param>
        /// <param name="ClassId">ClassID</param>
        /// <param name="iType">0:新增 1:修改</param>
        /// <returns></returns>
        public bool GetDatPhraseDetailByPhrasaeTextAndClassId(string strText, Guid ClassId, Guid PhraseId, int iType)
        {
            this.entity = new DatPhraseDetail();
            bool temp = false;
            if (iType == 0)
            {
                temp = GetEntityByCondition("PhraseText='" + strText + "' and ClassID='" + ClassId + "'") != null;
            }
            else
            {
                temp = GetEntityByCondition("PhraseID<>'" + PhraseId + "' and ClassID='" + ClassId + "' and PhraseText='" + strText + "'") != null;
            }
            return temp;
        }
    }
}
